﻿@using ExcellOnServices.Models;

@{
	List<Product> products = ViewBag.Products;
	Layout = null;
}

@if (products == null || !products.Any()) {
	<div class="alert alert-info">
		No products available.
	</div>
} else {
	<table class="table table-striped table-hover" id="table-products">
		<tr>
			<th class="text-center">Image</th>
			<th>Category</th>
			<th>Name</th>
			<th class="text-center">Price</th>
			<th class="text-center">Discount</th>
			<th class="text-center">Action</th>
		</tr>

		@foreach (var product in products) {
			<tr id="row-product-@product.Id" class="row-product" productId="@product.Id">
				<td>
					<img src="@product.ImageUrl" style="width:50px;" />
				</td>
				<td>
					@Html.DisplayFor(modelItem => product.Category.Name)
				</td>
				<td>
					@Html.DisplayFor(modelItem => product.Name)
				</td>
				<td>
					@Html.DisplayFor(modelItem => product.Price)
				</td>
				<td>
					@Html.DisplayFor(modelItem => product.Discount)
				</td>
				<td>
					<button class="select-product btn btn-primary" onclick="addProduct(@product.Id)">Select</button>
				</td>
			</tr>
		}
	</table>
}